<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/crm/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/crm/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="/static/crm/css/public.css" media="all">
    <meta name="referrer" content="no-referrer">
</head>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">

            <fieldset class="table-search-fieldset">
                <legend>搜索信息</legend>
                <div style="margin: 10px 10px 10px 10px">
                    <form class="layui-form layui-form-pane" action="">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">用户ID</label>
                                <div class="layui-input-inline">
                                    <input id="id" type="text" name="id" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">用户名称</label>
                                <div class="layui-input-inline">
                                    <input id="name" type="text" name="name" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">手机</label>
                                <div class="layui-input-inline">
                                    <input id="phone" type="text" name="phone" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button type="submit" class="layui-btn layui-btn-primary" lay-submit
                                    lay-filter="data-search-btn" id="search_btn"><i class="layui-icon"></i> 搜 索
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>

            <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm" style="background-color: #393D49;" lay-event="refresh"><i class="fa fa-refresh layui-anim-rotate"></i></button>
                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
            </div>
        </script>

            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        </div>
    </div>
    <script src="/static/crm/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script>
        layui.use(['form', 'table'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table;

            /**
             * 数据表格 
             * @Author: wjf
             * @Date: 2022-11-26 17:56:42
             */
            table.render({
                elem: '#currentTableId',
                url: 'list',
                toolbar: '#toolbarDemo',
                cols: [[
                    { type: "checkbox", width: 100 },
                    { field: 'id', width: 150, title: 'ID', sort: true },
                    { field: 'name', width: 150, title: '客户名称' },
                    { field: 'phone', width: 150, title: '手机' },
                    { field: 'sale_id', width: 150, title: '创建人' },
                    { field: 'super_id', width: 150, title: '负责人' },
                    { field: 'create_time', width: 150, title: '创建时间' },
                    { field: 'follow_time', width: 150, title: '跟进时间' },
                    { field: 'status', width: 150, title: '状态' },
                ]],
                limits: [10, 15, 20, 25, 50, 100],
                limit: 10,
                page: true,
                skin: 'line'
            });
            /**
             * 搜索
             * @Author: wjf
             * @Date: 2022-11-29 09:15:24
             */
            form.on('submit(data-search-btn)', function (data) {
                var data = data.field;
                table.reload('currentTableId', {
                    where: {
                        data: data      //where里面是传递到后台的值，我传递的是学生的学号id
                    },
                    url: 'list'    //url写你自己的servlet，这个servlet要接受where传递的数据并返回从数据库搜索的数据。
                    ,
                    page: {
                        curr: 1  //这里不用改，意思是从第一页开始重载表格
                    }
                });
                return false;
            });
            /**
             * toolbar监听事件
             */
            table.on('toolbar(currentTableFilter)', function (obj) {
                if (obj.event === 'add') {  // 监听添加操作
                    var index = layer.open({
                        title: '添加用户',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: ['80%', '80%'],
                        content: '/crm/client.ourclients/add',
                        end: function () {
                            table.reload('currentTableId', {
                                page: {
                                    curr: 1
                                }
                            }, 'data');
                        }
                    });
                } else if (obj.event === 'refresh') {  // 监听刷新操作
                    table.reload('currentTableId', {
                        page: {
                            curr: 1
                        }
                    }, 'data');
                }
            });
        });
    </script>

</body>

</html>